import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex) // vue的插件机制

// Vuex.Store 构造器选项
const store = new Vuex.Store({
    // 为了不和页面或组件的data中的造成混淆，state中的变量前面建议加上$符号
    state: {
        // 用户信息
        $userInfo: false,
		windowHeights: 0,
		windowWidths: 0,
		topheights: 0,
		bodyHeights: 0,
		statusBarHeight:0,
		Language:'zh-CN',
		timeOut:(new Date().getTimezoneOffset())*60000,
    },
	mutations:{
		postdata(state,{url='',data={},success=()=>{},error=()=>{}}){
			var newdata = data;
			newdata.Language = state.Language;
			var token = state.$userInfo?state.$userInfo.AccessToken:'';
			console.log(newdata)
			uni.$u.http.post(url,newdata,{header:{Token:token}}).then((e)=>{
				success(e)
			}).catch(err => {
				error(err)
			});
		},
	}
})

export default store
